﻿/*********************************************************************************
 *Author:         OnClick
 *Version:        1.0
 *UnityVersion:   2018.3.1f1
 *Date:           2019-03-23
 *Description:    IFramework
 *History:        2018.11--
*********************************************************************************/
using UnityEditor;
using UnityEngine;

namespace IFramework
{
	public class ScriptableObj
	{
        public static void Create<T>(string savePath) where T : ScriptableObject
        {
            ScriptableObject sto = ScriptableObject.CreateInstance<T>();
            AssetDatabase.CreateAsset(sto, savePath);
            EditorUtility.SetDirty(sto);
            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();
        }
        public static T Load<T>(string path) where T : ScriptableObject
        {
           return AssetDatabase.LoadAssetAtPath<T>(path);
        }
        public static void Update<T>(T t) where T : ScriptableObject
        {
            EditorUtility.SetDirty(t);
            AssetDatabase.SaveAssets();
            //Selection.activeObject = t;
            AssetDatabase.Refresh();
        }
    }
}
